package cn.crce.cloud9.simple;

import javax.swing.*;

/**
 * @author OnCloud9
 * @description
 * @project NRCE-TEST
 * @date 2022年09月10日 上午 11:04
 */
public class Case39 {
    public static void main(String args[]) {
        StringBuffer buf = new StringBuffer("你好!祝你成功!");
        String output = "buf = " + buf.toString() +
                "\nCharacter at 0: " + buf.charAt(0) +
                "\nCharacter at 4: " + buf.charAt(4);
//*********Found**********
        char charArray[] = new char[buf.length()];
//*********Found**********
        buf.getChars(0, buf.length(), charArray, 0);
        output += "\n\n在字符串缓存中的字符是: ";
//*********Found**********
        for (int i = 0; i < charArray.length; ++i)
            output += charArray[i];
        buf.setCharAt(0, '您');
        buf.setCharAt(6, '材');
//*********Found**********
        output += "\n\nbuf = " + buf.toString();
        buf.reverse();
        output += "\n\nbuf = " + buf.toString();
        JOptionPane.showMessageDialog(null, output,
                "字符串缓存的字符相关方法示范",
                JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
    }
}
